package com.asia5b.a5bmall.same.adapter

import android.widget.ImageView
import android.widget.TextView
import com.asia5b.a5bmall.same.R
import com.asia5b.a5mall.middleware.config.CountrysRepository
import com.asia5b.a5mall.middleware.model.member.CurrencyModel
import com.asia5b.a5mall.middleware.utils.WImageLoader
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder

/**
 * Created by zhangyuncai on 2019/11/15.
 */
class ChoiceCurrencyAdapter(
        list: ArrayList<CurrencyModel>
)
    : BaseQuickAdapter<CurrencyModel, BaseViewHolder>(R.layout.item_choicecurrency_adapter, list) {
    var select_currency = CountrysRepository.getCurrencySelect()

    override fun convert(helper: BaseViewHolder, item: CurrencyModel) {
        //国家旗帜
        val iv_choicecurrency_currencytag = helper.getView<ImageView>(R.id.iv_choicecurrency_currencytag)
        WImageLoader.displayImage(item.image_link,iv_choicecurrency_currencytag,R.drawable.image_error)
        //国家名称
        val tv_choicecurrency_currencyname = helper.getView<TextView>(R.id.tv_choicecurrency_currencyname)
        tv_choicecurrency_currencyname.text="${item.currency_short.toUpperCase()}"
        //App设置的语言
        val tv_choicecurrency_check = helper.getView<TextView>(R.id.tv_choicecurrency_check)
        tv_choicecurrency_check.isSelected = select_currency.country_id == item.country_id
    }
}